<!DOCTYPE html>

<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->

<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->

<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->

    <!-- BEGIN HEAD -->

    <head>

        <meta charset="utf-8" />

        <title><{:L('hjjp_title')}> | <{:L('saleset')}> | <{:L('salerule')}></title>

        <meta content="width=device-width, initial-scale=1.0" name="viewport" />

        <meta content="" name="description" />

        <meta content="" name="author" />

        <!-- BEGIN GLOBAL MANDATORY STYLES -->

        <link href="__PUBLIC__/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>

        <link href="__PUBLIC__/css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css"/>

        <link href="__PUBLIC__/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>

        <link href="__PUBLIC__/css/style-metro.css" rel="stylesheet" type="text/css"/>

        <link href="__PUBLIC__/css/style.css" rel="stylesheet" type="text/css"/>

        <link href="__PUBLIC__/css/style-responsive.css" rel="stylesheet" type="text/css"/>

        <link href="__PUBLIC__/css/<{$ctype}>.css" rel="stylesheet" type="text/css" id="style_color"/>

        <link href="__PUBLIC__/css/uniform.default.css" rel="stylesheet" type="text/css"/>

        <link href="__PUBLIC__/css/scojs.css" rel="stylesheet" type="text/css"/>
        <!-- END GLOBAL MANDATORY STYLES -->

        <!-- BEGIN PAGE LEVEL STYLES -->
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/datepicker.css" />

        <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/daterangepicker.css" />

        <link rel="stylesheet" href="__PUBLIC__/css/select2_metro.css" />

        <link rel="stylesheet" href="__PUBLIC__/css/DT_bootstrap.css" />

        <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/jquery-ui-1.10.1.custom.min.css" />

        <link href="__PUBLIC__/css/bootstrap-modal.css" rel="stylesheet" type="text/css"/>

        <!-- END PAGE LEVEL STYLES -->

        <link rel="shortcut icon" href="__PUBLIC__/image/favicon.ico" />

    </head>

    <!-- END HEAD -->

    <!-- BEGIN BODY -->

    <body class="page-header-fixed">

    <include file="Public/header" />

    <include file="Public/nav" />

    <!-- BEGIN PAGE TITLE & BREADCRUMB-->

    <h3 class="page-title">

        <{:L('saleset')}> <small><{:L('salerule')}></small>

    </h3>

    <ul class="breadcrumb">

        <li>

            <i class="icon-home"></i>

            <a href="__ROOT__/Index/index.html"><{:L('home')}></a> 

            <i class="icon-angle-right"></i>

        </li>

        <li>

            <a href="#"><{:L('saleset')}></a>

            <i class="icon-angle-right"></i>

        </li>

        <li><a href="#"><{:L('salerule')}></a></li>

    </ul>

    <!-- END PAGE TITLE & BREADCRUMB-->

</div>

</div>

<!-- END PAGE HEADER-->

<!-- BEGIN PAGE CONTENT-->

<div class="row-fluid">

    <div class="span12">

        <div class="portlet box light-grey">

            <div class="portlet-title">

                <div class="caption"><i class="icon-cogs"></i><{:L('salerule')}></div>

                <div class="tools">

                    <a href="javascript:;" class="collapse"></a>

                    <a href="javascript:;" class="reload"></a>

                </div>

            </div>


            <div class="portlet-body">

                <div class="clearfix">

                    <div class="btn-group">

                        <button id="create-act" class="btn green">

                            <{:L('create')}> <i class="icon-plus"></i>

                        </button>

                    </div>

                </div>

                <table class="table table-striped table-bordered table-hover table-full-width" id="sale_table">

                    <thead>

                        <tr>

                            <th><{:L('number')}></th>

                            <th><{:L('name')}></th>

                            <th><{:L('salecategory')}></th>
                            <th><{:L('price')}></th>



                            <th class="span2"><{:L('visible')}></th>

                            <th class="span2"><{:L('act')}></th>

                        </tr>

                    </thead>

                    <tbody>

                    <foreach name="saleruleList" item="salerule">

                        <tr >

                            <td><{$salerule.id}></td>

                            <td><{$salerule.rulename}></td>

                            <td>
                                <input type="hidden" name="categoryId" value="<{$salerule.rulecategoryid}>" />
                                <div class="hide" name="feature">
                                    <div>
                                        <foreach name="salerule.rulefood" item="food"><input type="hidden" class="food_<{$salerule.id}>" data-food="<{$food.id}>" value="<{$food.name}>" /><{$food.name}>&nbsp;&nbsp;  </foreach>
                                    </div>
                                    <div>
                                        <foreach name="salerule.ruleregion" item="region"><input type="hidden" class="region_<{$salerule.id}>" data-region="<{$region.id}>" value="<{$region.name}>" /><{$region.name}>&nbsp;&nbsp;  </foreach>
                                    </div>
                                    <div>
                                        <span><{$starttime}></span><span><{$salerule.start_time}></span>      
                                    </div>
                                    <div>
                                        <span><{$stoptime}></span><span><{$salerule.stop_time}></span>      
                                    </div>

                                </div>

                                <{$salerule.category.name}>
                            </td>
                            <td><{$salerule.price}></td>



                            <td>
                                <input type="hidden" name="visualable" value="<{$salerule.visible}>" />
                        <if condition="$salerule.visible eq 'v'">
                            <span><{:L('yes')}></span>
                            <elseif condition="$food.visible eq 'n'" />
                            <span class="red"><{:L('no')}></span>
                            <else />
                            <span class="red"><{:L('notsale')}></span>
                        </if>
                        </td>

                        <td>

                            <a href="#" class="btn blue icn-only">

                                <i class="icon-edit"></i>

                            </a>


                            <a href="#" class="btn red icn-only">

                                <i class="icon-remove icon-white"></i>

                            </a>

                        </td>

                        </tr>

                    </foreach>

                    </tbody>

                </table>

            </div>

        </div>

        <!-- END EXAMPLE TABLE PORTLET-->

        <!-- BEGIN EDIT MODAL-->

            <div id="editmodal" class="modal hide fade" tabindex="-1" data-width="640">

                <form id="modalform" action="#" class="form-horizontal">

                    <div class="modal-header">

                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>

                        <h3><{:L('salerule')}><{:L('edit')}></h3>

                    </div>

                    <div class="modal-body">

                        <div class="row-fluid">

                            <div class="span12">

                                <div class="alert alert-error hide">

                                    <button class="close" data-dismiss="alert"></button>

                                    <{:L('formerror')}>

                                </div>

                                <div class="control-group">

                                    <label class="control-label"><{:L('salerule')}><{:L('number')}></label>

                                    <div class="controls">

                                        <input id="ruleid" class="span6 m-wrap" type="text" name="ruleid" placeholder="<{:L('readonly')}>" readonly="" />

                                        <span class="help-inline"><{:L('idhint')}></span>

                                    </div>

                                </div>
                                <div class="control-group">

                                    <label class="control-label"><{:L('date_time')}><span class="required">*</span>:</label>

                                    <div class="controls">

                                        <div class="input-prepend">

                                            <span class="add-on"><i class="icon-calendar"></i></span><input id="date_time" type="text" name="date_time" class="m-wrap date-range" />

                                        </div>

                                    </div>

                                </div>

                                <div class="control-group">

                                    <label class="control-label"><{:L('salerule')}><{:L('name')}><span class="required">*</span>:</label>

                                    <div class="controls">

                                        <input type="text" id="rulename" name="rulename" class="span6 m-wrap popovers" data-required="1"  data-trigger="hover" data-content="<{:L('namehint')}>" data-original-title="<{:L('inputtips')}>" />

                                    </div>

                                </div>

                                <div class="control-group">

                                    <label class="control-label"><{:L('salecategory')}><span class="required">*</span>:</label>

                                    <div class="controls">

                                        <select class="span6 m-wrap" id="rulecategoryid" name="rulecategoryid" data-placeholder="<{:L('select')}><{:L('category')}>" tabindex="1">

                                            <option value="-1"><{:L('select')}>...</option>

                                            <foreach name="categoryList" item="cate">

                                                <option value="<{$cate.id}>"><{$cate.name}></option>

                                            </foreach>

                                        </select>

                                    </div>

                                </div>

                                <div class="control-group">

                                    <label class="control-label"><{:L('food')}><{:L('name')}><span class="required">*</span>:</label>

                                    <div class="controls">

                                        <select id="rulefood" class="span4">

                                            <option value="-1"><{:L('addOption')}></option>

                                            <foreach name="foodlist" item="food">

                                                <option value="<{$food.id}>"><{$food.name}></option>

                                            </foreach>

                                        </select>

                                        <a href="javascript:;" class="btn green left"  onclick="addBadge('#rulefood', '#foodContainer', 'food');"><i class="icon-plus"></i>  <{:L('create')}></a>

                                        <div id="foodContainer">

<!--                                                                                        <volist name="saleruleList.rulefood" id="selectedFood">
                                                                                            <div class="badge badge-large">
                                                                                                <span><{$selectedFood.name}></span>
                                                                                                <input type="hidden" name="foodBelongs[]" value="<{$selectedFood.id}>" />
                                                                                                <button type="button" class="close cred badge-close"></button>
                                                                                            </div>
                                                                                        </volist>-->

                                        </div>

                                    </div>

                                </div>


                                <div class="control-group">

                                    <label class="control-label"><{:L('price')}><span class="required">*</span>:</label>

                                    <div class="controls">

                                        <input type="text" id="price" name="price" class="span6 m-wrap popovers" data-required="1"  data-trigger="hover" data-content="<{:L('goodsprice')}>" data-original-title="<{:L('inputtips')}>" />

                                    </div>

                                </div>

                                <div class="control-group">

                                    <label class="control-label"><{:L('region')}>:</label>

                                    <div class="controls">

                                        <select id="ruleregion" class="span4" >

                                            <option value="-1"><{:L('addOption')}></option>

                                            <foreach name="regionlist" item="region">

                                                <option value="<{$region.id}>"><{$region.name}></option>

                                            </foreach>

                                        </select>

                                        <a href="javascript:;" class="btn green left" onclick="addBadge('#ruleregion', '#regionContainer', 'region');"><i class="icon-plus"></i>  <{:L('create')}></a>

                                        <div id="regionContainer">

<!--                                                                                        <volist name="saleruleList.ruleregion" id="selectedRegion">
                                                                                            <div class="badge badge-large">
                                                                                                <span><{$selectedRegion.name}></span>
                                                                                                <input type="hidden" name="regionBelongs[]" value="<{$selectedRegion.id}>" />
                                                                                                <button type="button" class="close cred badge-close"></button>
                                                                                            </div>
                                                                                        </volist>-->

                                        </div>

                                    </div>

                                </div>


                                


                                <div class="control-group">

                                    <label class="control-label"><{:L('visible')}>:</label>

                                    <div class="controls">

                                        <label class="radio">

                                            <input type="radio" name="visible" data-default="true" value="v" checked="" />

                                            <{:L('yes')}>

                                        </label>

                                        <label class="radio">

                                            <input type="radio" name="visible" value="n" />

                                            <{:L('no')}>

                                        </label>

                                        <label class="radio">

                                            <input type="radio" name="visible" value="ns" />

                                            <{:L('notsale')}>

                                        </label>

                                    </div>

                                </div>

                            </div>

                        </div>

                    </div>

                    <div class="modal-footer form-actions">

                        <input type="hidden" value="" id="actionType" />

                        <button type="button" data-dismiss="modal" class="btn"><{:L('cancle')}></button>

                        <button type="submit" class="btn blue"><{:L('save')}></button>

                    </div>

                </form>

            </div>

        <!-- BEGIN EDIT MODAL-->

    </div>

</div>
<!-- END PAGE CONTENT-->

</div>

<!-- END PAGE CONTAINER-->

</div>

<!-- END PAGE -->

</div>

<!-- END CONTAINER -->

<include file="Public/footer" />

<!-- BEGIN PAGE LEVEL PLUGINS -->
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-datepicker.js"></script>

<script type="text/javascript" src="__PUBLIC__/js/date.js"></script>

<script type="text/javascript" src="__PUBLIC__/js/daterangepicker.js"></script> 

<script type="text/javascript" src="__PUBLIC__/js/jquery.dataTables.js"></script>

<script type="text/javascript" src="__PUBLIC__/js/DT_bootstrap.js"></script>

<!-- END PAGE LEVEL PLUGINS -->

<!-- BEGIN PAGE LEVEL SCRIPTS -->

<script src="__PUBLIC__/js/app.js"></script>
<script src="__PUBLIC__/js/handledaterange-cn.js"></script>

<script src="__PUBLIC__/js/table-sale.js"></script>


<script>

                                            jQuery(document).ready(function() {

                                                App.init();

                                                TableSale.init('sale_table');

                                                AjaxModal.init('editmodal', 'Sale', 'sale', {
                                                    rulename: {
                                                        minlength: 2,
                                                        required: true
                                                    },
                                                    rulecategoryid: {
                                                        min: 1,
                                                        required: true
                                                    },
                                                    price: {
                                                        required: true
                                                    },
                                                    date_time: {
                                                        required: true
                                                    }
                                                });



                                                Daterange.daterangePickers('.date-range');


                                                $("#sale_table").delegate("a", "click", function(event) {
                                                    var targetNode = event.srcElement || event.target;
                                                    var targetObj = $(targetNode);
                                                    if (!targetObj.hasClass("btn")) {
                                                        targetObj = targetObj.parent();
                                                    }
                                                    if (targetObj.hasClass("blue")) {
                                                        $("#ruleid").val(targetObj.parent().parent().find("td").eq(1).html());
                                                        $("#rulename").val(targetObj.parent().parent().find("td").eq(2).html());
                                                        $("#rulecategoryid").val(targetObj.parent().parent().find("td").eq(3).find("input").val());

                                                        $ruleid = targetObj.parent().parent().find("td").eq(1).html();
                                                        addBadgeBackground('.food_' + $ruleid, '#foodContainer', 'food');
                                                        addBadgeBackground('.region_' + $ruleid, '#regionContainer', 'region');




//                                                        $("#foodBelongs").val(targetObj.parent().parent().find("td").eq(3).html());
                                                        $("#price").val(targetObj.parent().parent().find("td").eq(4).html());
//                                                        $("#regionBelongs").val(targetObj.parent().parent().find("td").eq(5).html());
//                                                        $("#start_time").val(targetObj.parent().parent().find("td").eq(6).html());
//                                                        $("#stop_time").val(targetObj.parent().parent().find("td").eq(7).html());
                                                        $("#editmodal").find("input[type=radio][name=visible]").each(function() {
                                                            if ($(this).val() == targetObj.parent().parent().find("td").eq(5).find("input").val()) {
                                                                $(this).parent().addClass("checked");
                                                            } else {
                                                                $(this).parent().removeClass("checked");
                                                            }
                                                        });
                                                        $("#actionType").val("edit");
                                                        $('body').modalmanager('loading');
                                                        setTimeout(function() {
                                                            $("#editmodal").modal();
                                                        }, 500);
                                                    } else if (targetObj.hasClass("red")) {
                                                        var confirm = $.scojs_confirm({
                                                            content: "<{:L('sureDelete')}>",
                                                            action: function() {
                                                                deleteAction("Sale", {id: targetObj.parent().parent().find("td").eq(1).html(), method: "sale"});
                                                            }
                                                        });
                                                        confirm.show();
                                                    }
                                                });
                                                
                                                $("#editmodal").delegate("button.badge-close", "click", function() {
                                                    removeBadge(this);
                                                });

                                            });

</script>


<script type="text/javascript">
//var _gaq = _gaq || [];  _gaq.push(['_setAccount', 'UA-37564768-1']);  _gaq.push(['_setDomainName', 'keenthemes.com']);  _gaq.push(['_setAllowLinker', true]);  _gaq.push(['_trackPageview']);  
//(function() {    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;    ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);  })();
</script>

</body>

<!-- END BODY -->

</html>